#!/bin/bash
. ./var
. ./Tmpdir
maven(){
    MVN="apache-maven-3.6.3-bin.tar.gz"
    TARMVN="apache-maven-3.6.3"

    #调用Tmpdir
    Tmpdir
    cd $dir && wget -V &> /dev/null || yum -y install wget
    mvn -v &> /dev/null && echoRed "检测到系统中有mvn命令，故而退出" && rm -rf $dir && exit 1

    wget $ip/${MVN} && tar xf ${MVN} -C /usr/local
    ln -sv /usr/local/${TARMVN} /usr/local/apache-maven
    
    echo "MAVEN_HOME=/usr/local/${TARMVN}" >> /etc/profile && echo 'PATH=$PATH:$MAVEN_HOME/bin' >> /etc/profile && source /etc/profile
    /usr/local/${TARMVN}/bin/mvn -v &> /dev/null && echoGreen "已完成安装，可尽情享用" || echoYellow "可能安装有问题，请检查" 
    S && rm -rf $dir
}
